import request from '@/config/axios'

export interface EvalApplicationConditionVO {
  id?: number
  conditionName: string
  professionCode: string
  skillLevel: string
  evaluationMethod: string
  conditionType: string
  conditionParameters?: string
  validationRules?: string
  isRequired: boolean
  logicOperator?: string
  conditionOrder: number
  conditionStatus: number
  createTime?: Date
}

export interface EvalApplicationConditionPageReqVO extends PageParam {
  conditionName?: string
  professionCode?: string
  skillLevel?: string
  evaluationMethod?: string
  conditionType?: string
  isRequired?: boolean
  conditionStatus?: number
  createTime?: Date[]
}

export interface EvalApplicationConditionSaveReqVO {
  id?: number
  conditionName: string
  professionCode: string
  skillLevel: string
  evaluationMethod: string
  conditionType: string
  conditionParameters?: string
  validationRules?: string
  isRequired: boolean
  logicOperator?: string
  conditionOrder: number
  conditionStatus: number
}

// 查询申报条件分页
export const getApplicationConditionPage = (params: EvalApplicationConditionPageReqVO) => {
  return request.get({ url: '/eval/application-condition/page', params })
}

// 查询申报条件详情
export const getApplicationCondition = (id: number) => {
  return request.get({ url: '/eval/application-condition/get?id=' + id })
}

// 新增申报条件
export const createApplicationCondition = (data: EvalApplicationConditionSaveReqVO) => {
  return request.post({ url: '/eval/application-condition/create', data })
}

// 修改申报条件
export const updateApplicationCondition = (data: EvalApplicationConditionSaveReqVO) => {
  return request.put({ url: '/eval/application-condition/update', data })
}

// 删除申报条件
export const deleteApplicationCondition = (id: number) => {
  return request.delete({ url: '/eval/application-condition/delete?id=' + id })
}

// 导出申报条件 Excel
export const exportApplicationCondition = (params: EvalApplicationConditionPageReqVO) => {
  return request.download({ url: '/eval/application-condition/export-excel', params })
}

// 根据计划ID和专业代码获取申报条件列表
export const getApplicationConditionListByPlanAndProfession = (planId: number, professionCode: string) => {
  return request.get({ url: '/eval/application-condition/list-by-plan-and-profession?planId=' + planId + '&professionCode=' + professionCode })
}

// 批量创建申报条件
export const batchCreateApplicationConditions = (data: EvalApplicationConditionSaveReqVO[]) => {
  return request.post({ url: '/eval/application-condition/batch-create', data })
}

// 启用/禁用申报条件
export const toggleApplicationConditionStatus = (id: number, isActive: boolean) => {
  return request.put({ url: '/eval/application-condition/toggle-status?id=' + id + '&isActive=' + isActive })
}
